import re

class Validate:
    def __init__( self ):
        pass

    def lenght( self, value, _max, _min = 1 ):
        if not ( _min <= len( value ) <= _max ):
            return False
        return True

    def validate( self, value, regexp ):
        p = re.compile( regexp )
        if p.match( value ):
            r = True
        else:
            r = False
        return r

    def email( self, value, regexp = "^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,6}$" ):
        return self.validate( value, regexp )

    def login( self, value, regexp = "^[A-Za-z]+$" ):
        if self.validate( value, regexp ):
            return self.lenght( value, 15, 4 )
        else:
            return False

    def passwd( self, value, regexp = "^[A-Za-z0-9]+$" ):
        if self.validate( value, regexp ):
            return self.lenght( value, 20, 6 )
        else:
            return False
